//
//  PostImageView.m
//  Pension
//
//  Created by  YIQI on 2019/4/2.
//  Copyright © 2019年  YIQI. All rights reserved.
//

#import "PostImageCell.h"
#import "YQGoodsOrderModel.h"
@interface PostImageCell ()<UITextViewDelegate>

@property (nonatomic,strong)UILabel *titleLabel;


@property (nonatomic, strong) UICollectionView * collView;
@end

@implementation PostImageCell
- (void)setItemModel:(YQGoodsOrderItemModel *)itemModel {
    _itemModel = itemModel;
    self.xmView.text = itemModel.connent;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 12, 160, 21)];
        self.titleLabel.text = kYQLS(@"备注");
        self.titleLabel.textColor = kAPPMainTitleColor;
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.titleLabel];
        
        self.xmView = [[IQTextView alloc] initWithFrame:CGRectMake(15, 40, kYQPScreenWidth-30, 47)];
        self.xmView.placeholder = kYQLS(@"请输入简短文字");
        self.xmView.placeholderTextColor = kAPPThreeTitleColor;
        self.xmView.textColor = kAPPMainTitleColor;
        self.xmView.font = [UIFont systemFontOfSize:12];
        self.xmView.delegate = self;
        [self.contentView addSubview:self.xmView];
        
    }
    return self;
}

- (void)addButtonClick {
    if (_addPostImageSourceBlock) {
        _addPostImageSourceBlock();
    }
}

-(void)textViewDidEndEditing:(UITextView *)textView {
    self.itemModel.connent = textView.text;
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    NSString * toBeString = [textView.text stringByReplacingCharactersInRange:range withString:text]; //得到输入框的内容
    self.itemModel.connent = toBeString;
    return YES;
}

@end
